<!--
  This file is a part of the open-eBackup project.
  This Source Code Form is subject to the terms of the Mozilla Public License, v. 2.0.
  If a copy of the MPL was not distributed with this file, You can obtain one at
  http://mozilla.org/MPL/2.0/.
  
  Copyright (c) [2024] Huawei Technologies Co.,Ltd.
  
  THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND,
  EITHER EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT,
  MERCHANTABILITY OR FIT FOR A PARTICULAR PURPOSE.
  -->


<!DOCTYPE html
  PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html lang="zh-cn" xml:lang="zh-cn">
<head>
      <meta http-equiv="Content-Type" content="text/html; charset=utf-8">
   
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="DC.Type" content="topic">
<meta name="DC.Title" content="检查并配置Oracle数据库的归档模式">
<meta name="product" content="">
<meta name="DC.Relation" scheme="URI" content="oracle_gud_0015.html">
<meta name="prodname" content="">
<meta name="version" content="">
<meta name="brand" content="">
<meta name="DC.Publisher" content="20250306">
<meta name="prodname" content="csbs">
<meta name="documenttype" content="usermanual">
<meta name="DC.Format" content="XHTML">
<meta name="DC.Identifier" content="oracle_gud_0017">
<meta name="DC.Language" content="zh-cn">
<link rel="stylesheet" type="text/css" href="public_sys-resources/commonltr.css">
<title>检查并配置Oracle数据库的归档模式</title>
</head>
<body style="clear:both; padding-left:10px; padding-top:5px; padding-right:5px; padding-bottom:5px"><a name="oracle_gud_0017"></a><a name="oracle_gud_0017"></a>

<h1 class="topictitle1">检查并配置Oracle数据库的归档模式</h1>
<div><p>执行备份时，需要开启Oracle数据库的归档模式。</p>
<div class="section"><h4 class="sectiontitle">前提条件</h4><ul><li>如果Oracle数据库的归档日志存放在闪回区，闪回区空间有限，空间用尽时将导致生产环境异常。请确保闪回区空间能够容纳5天的归档日志，并实时监控闪回区空间利用率。</li><li>如果Oracle数据库的归档日志存放在本地路径，请确保Oracle数据库的安装用户（默认为<strong>oracle</strong>）对该归档路径有读写权限，且归档路径所在目录有剩余空间。</li></ul>
</div>
<div class="section"><h4 class="sectiontitle">操作步骤</h4><ol><li><span>登录Oracle数据库主机。</span><p><ul id="oracle_gud_0017__oracle_gud_0020_zh-cn_topic_0000001656760969_ul1983714162204"><li id="oracle_gud_0017__oracle_gud_0020_zh-cn_topic_0000001656760969_li7258697580">如果是Linux操作系统，请使用PuTTY登录Oracle数据库主机，并执行<strong id="oracle_gud_0017__oracle_gud_0020_zh-cn_topic_0000001656760969_b119369483451">su - oracle</strong>命令，切换到<strong id="oracle_gud_0017__oracle_gud_0020_zh-cn_topic_0000001656760969_b2486163014495">oracle</strong>账户。</li><li id="oracle_gud_0017__oracle_gud_0020_zh-cn_topic_0000001656760969_li1366015032013">如果是Windows操作系统，请使用系统管理员登录Oracle数据库主机。</li></ul>
</p></li><li><span>执行以下命令，登录Oracle数据库实例。</span><p><ul id="oracle_gud_0017__oracle_gud_0016_ul7420345341"><li id="oracle_gud_0017__oracle_gud_0016_li15682124913711">OS认证：<ul id="oracle_gud_0017__oracle_gud_0016_ul89443983816"><li id="oracle_gud_0017__oracle_gud_0016_li18420124173415">如果是Linux操作系统，请执行以下命令：<p id="oracle_gud_0017__oracle_gud_0016_p95148598366"><a name="oracle_gud_0017__oracle_gud_0016_li18420124173415"></a><a name="oracle_gud_0016_li18420124173415"></a><strong id="oracle_gud_0017__oracle_gud_0016_b14236563719">export ORACLE_SID=</strong><em id="oracle_gud_0017__oracle_gud_0016_i85144598369">数据库实例名称</em></p>
<p id="oracle_gud_0017__oracle_gud_0016_p145141259153613"><strong id="oracle_gud_0017__oracle_gud_0016_b1597618293715">sqlplus / as sysdba</strong></p>
</li><li id="oracle_gud_0017__oracle_gud_0016_li7402151163816">如果是Windows操作系统，请执行以下操作：<ol type="a" id="oracle_gud_0017__oracle_gud_0016_ol124110408264"><li id="oracle_gud_0017__oracle_gud_0016_li624120402267">在键盘上按<span class="uicontrol" id="oracle_gud_0017__oracle_gud_0016_oracle_gud_0016_uicontrol11819941114510">“Win+R”</span>，打开运行窗口。</li><li id="oracle_gud_0017__oracle_gud_0016_li161821338277">输入<span class="parmvalue" id="oracle_gud_0017__oracle_gud_0016_parmvalue122291222476">“cmd”</span>，执行以下命令。<p id="oracle_gud_0017__oracle_gud_0016_p1755152313372"><strong id="oracle_gud_0017__oracle_gud_0016_b19591532143713">set ORACLE_SID=</strong><em id="oracle_gud_0017__oracle_gud_0016_i16755423133718">数据库实例名称</em></p>
<p id="oracle_gud_0017__oracle_gud_0016_p1075515234379"><strong id="oracle_gud_0017__oracle_gud_0016_b540852910371">sqlplus / as sysdba</strong></p>
</li></ol>
</li></ul>
</li><li id="oracle_gud_0017__oracle_gud_0016_li105571236103417">数据库认证：<ul id="oracle_gud_0017__oracle_gud_0016_ul1136516538386"><li id="oracle_gud_0017__oracle_gud_0016_li1723334817382">如果是Linux操作系统，请执行以下命令：<p id="oracle_gud_0017__oracle_gud_0016_p920984963717"><a name="oracle_gud_0017__oracle_gud_0016_li1723334817382"></a><a name="oracle_gud_0016_li1723334817382"></a><strong id="oracle_gud_0017__oracle_gud_0016_b19174355163720">export ORACLE_SID=</strong><em id="oracle_gud_0017__oracle_gud_0016_i1420924973715">数据库实例名称</em></p>
<p id="oracle_gud_0017__oracle_gud_0016_p182093496371"><strong id="oracle_gud_0017__oracle_gud_0016_b034785743716">sqlplus</strong></p>
<p id="oracle_gud_0017__oracle_gud_0016_p17915722412">根据提示输入具备<strong id="oracle_gud_0017__oracle_gud_0016_b1691518214115">sysdba</strong>权限的用户：</p>
<pre class="screen" id="oracle_gud_0017__oracle_gud_0016_screen9915112104114"><em id="oracle_gud_0017__oracle_gud_0016_i1915102164113">username </em>as sysdba</pre>
<p id="oracle_gud_0017__oracle_gud_0016_p159150224117">根据提示输入密码。</p>
</li><li id="oracle_gud_0017__oracle_gud_0016_li122822426407">Windows OS执行以下命令：<ol type="a" id="oracle_gud_0017__oracle_gud_0016_ol587720252273"><li id="oracle_gud_0017__oracle_gud_0016_li5168124414479">在键盘上按<span class="uicontrol" id="oracle_gud_0017__oracle_gud_0016_oracle_gud_0016_uicontrol11819941114510_1">“Win+R”</span>，打开运行窗口。</li><li id="oracle_gud_0017__oracle_gud_0016_li3877172517270">输入<span class="parmvalue" id="oracle_gud_0017__oracle_gud_0016_parmvalue2059612503475">“cmd”</span>，执行以下命令。<p id="oracle_gud_0017__oracle_gud_0016_p8745723103813"><strong id="oracle_gud_0017__oracle_gud_0016_b9408122923816">set ORACLE_SID=</strong><em id="oracle_gud_0017__oracle_gud_0016_i12745162318389">数据库实例名称</em></p>
<p id="oracle_gud_0017__oracle_gud_0016_p15745182333814"><strong id="oracle_gud_0017__oracle_gud_0016_b11154427163811">sqlplus</strong></p>
<p id="oracle_gud_0017__oracle_gud_0016_p71274192512">根据提示输入具备<strong id="oracle_gud_0017__oracle_gud_0016_b17349199162611">sysdba</strong>权限的用户：</p>
<pre class="screen" id="oracle_gud_0017__oracle_gud_0016_screen18896121620243"><em id="oracle_gud_0017__oracle_gud_0016_i380114413256">username </em>as sysdba</pre>
<p id="oracle_gud_0017__oracle_gud_0016_p15251105852511">根据提示输入密码。</p>
</li></ol>
</li></ul>
</li></ul>
</p></li><li><span>执行以下命令查看是否开启归档模式。</span><p><p><strong>archive log list;</strong></p>
<p>回显类似如下表示已开启归档模式：</p>
<pre class="screen">SQL&gt; archive log list;
<strong>Database log mode              Archive Mode</strong>
Automatic archival             Enabled
Archive destination            USE_DB_RECOVERY_FILE_DEST
Oldest online log sequence     19
Next log sequence to archive   21
Current log sequence           21</pre>
</p></li><li><span>当未开启归档模式时，需执行命令开启归档模式。</span><p><ul><li>如果是单机场景，请执行以下命令。<div class="note"><img src="public_sys-resources/note_3.0-zh-cn.png"><span class="notetitle"> </span><div class="notebody"><p>在开启数据库归档模式过程中会关闭数据库。此操作会有一定的停机时间，需要注意停机时间再进行处理。</p>
</div></div>
<pre class="screen">shutdown immediate;
startup mount;
alter system set log_archive_dest_1='location=<em>归档日志存放路径</em>';
alter database archivelog;
alter database open;</pre>
</li><li>如果是RAC集群场景，需要在每个节点执行以下命令。对于ASM实例，<em>归档日志存放路径</em>请使用ASM共享磁盘组路径。<pre class="screen">shutdown immediate;
startup mount;
alter system set log_archive_dest_1='location=<em>归档日志存放路径</em>';
alter database archivelog;
alter database open;</pre>
</li></ul>
</p></li></ol>
</div>
</div>
<div>
<div class="familylinks">
<div class="parentlink"><strong>父主题：</strong> <a href="oracle_gud_0015.html">步骤1：检查并配置数据库环境</a></div>
</div>
</div>

<div class="hrcopyright"><hr size="2"></div><div class="hwcopyright">版权所有 &copy; 华为技术有限公司</div></body>
</html>